//
//  gouwuTableViewCell.m
//  BAOASystem
//
//  Created by michael on 2018/4/23.
//  Copyright © 2018年 czd. All rights reserved.
//

#import "gouwuTableViewCell.h"
#import "OALoginViewController.h"
#import "fajianxqViewController.h"
@implementation gouwuTableViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
if (self) {
_upview = [[UIView alloc]init];
_upview.backgroundColor = [UIColor colorWithHexString:@"f0eff5"];
       [self.contentView addSubview:_upview];
    
_lineview = [[UIView alloc]init];
_lineview.backgroundColor = [UIColor colorWithHexString:@"f0eff5"];
       [self.contentView addSubview:_lineview];
    
       _upview = [[UIView alloc]init];
_upview.backgroundColor = [UIColor colorWithHexString:@"f0eff5"];
       [self.contentView addSubview:_upview];
 _label1 = [[UILabel alloc]init];
    _label1.frame = CGRectZero;
        _label1.textColor = [UIColor colorWithHexString:@"484848"];
      [_label1 setFont:[UIFont systemFontOfSize:16]];
       [self.contentView addSubview:_label1];
    
        _label2 = [[UILabel alloc]init];
    _label2.frame = CGRectZero;
        _label2.textColor = [UIColor colorWithHexString:@"484848"];
      [_label2 setFont:[UIFont systemFontOfSize:14]];
       [self.contentView addSubview:_label2];
    
 _label3 = [[UILabel alloc]init];
    _label3.frame = CGRectZero;
        _label3.textColor = [UIColor colorWithHexString:@"a1a1a1"];
      [_label3 setFont:[UIFont systemFontOfSize:12]];
       [self.contentView addSubview:_label3];
    
 _label4 = [[UILabel alloc]init];
    _label4.frame = CGRectZero;
        _label4.textColor = [UIColor colorWithHexString:@"a1a1a1"];
      [_label4 setFont:[UIFont systemFontOfSize:12]];
       [self.contentView addSubview:_label4];
    
 _label5 = [[UILabel alloc]init];
    _label5.frame = CGRectZero;
        _label5.textColor = [UIColor colorWithHexString:@"a1a1a1"];
      [_label5 setFont:[UIFont systemFontOfSize:12]];
       [self.contentView addSubview:_label5];
    
        _label6 = [[UILabel alloc]init];
    _label6.frame = CGRectZero;
        _label6.textColor = [UIColor colorWithHexString:@"a1a1a1"];
      [_label6 setFont:[UIFont systemFontOfSize:12]];
       [self.contentView addSubview:_label6];
    
_picimage = [[UIImageView alloc]init];
        _picimage.frame = CGRectZero;
          [self.contentView addSubview:_picimage];
    
          _logoimage = [[UIImageView alloc]init];
        _logoimage.frame = CGRectZero;
          [self.contentView addSubview:_logoimage];

 _sendbutton = [UIButton buttonWithType:UIButtonTypeCustom];
    [_sendbutton addTarget:self action:@selector(sendaction) forControlEvents:UIControlEventTouchUpInside];
    [self.contentView addSubview:_sendbutton];


}

return self;

}
- (void)sendaction{
   UIStoryboard * storyBoard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];


    if (![[[NSUserDefaults standardUserDefaults]objectForKey:@"autoLogin"]isEqualToString:@"Y"]&&![[DanLi sharedDanLi].stay isEqualToString:@"yes"]) {
      OALoginViewController * loginVC = [storyBoard instantiateViewControllerWithIdentifier:@"LoginVC"];
        UINavigationController * navVC = [[UINavigationController alloc]initWithRootViewController:loginVC];
        loginVC.navigationController.navigationBar.hidden = YES;
                 self.ViewController.view.window.rootViewController = navVC;

}else{
fajianxqViewController *vc = [[fajianxqViewController alloc]init];
vc.hidesBottomBarWhenPushed = YES;

//@property (strong, nonatomic)  NSString *toMemberCompanyId;
//@property (strong, nonatomic)  NSString *toMemberNameId;
//
//@property (strong, nonatomic)  NSString *productId;

NSDictionary *dict = _dic[@"product"];
vc.productId = dict[@"id"];
vc.toMemberNameId = dict[@"uid"];

vc.toMemberCompanyId = dict[@"cpid"];
[self.ViewController.navigationController pushViewController:vc animated:YES];

}
}
- (void)layoutSubviews{
NSDictionary *dict = _dic[@"product"];
[super layoutSubviews];
_upview.frame = CGRectMake(0, 0, KScreenWidth, 5);
_logoimage.frame = CGRectMake(10, _upview.bottom+5, 20, 20);
_logoimage.image = [UIImage imageNamed:@"公司主页-选中"];
_label1.frame = CGRectMake(_logoimage.right+10, _upview.bottom, KScreenWidth-40, 29);
_lineview.frame = CGRectMake(0, _label1.bottom, KScreenWidth, 1);
_picimage.frame = CGRectMake(5, _lineview.bottom+5, 100, 100);
[_picimage sd_setImageWithURL:[NSURL URLWithString:dict[@"pdimg"]] placeholderImage:[UIImage imageNamed:@"加载"]];
_label2.frame = CGRectMake(_picimage.right+5, _picimage.top, KScreenWidth-120, 20);
_label3.frame = CGRectMake(_picimage.right+5, _label2.bottom, KScreenWidth-120, 15);
_label4.frame = CGRectMake(_picimage.right+5, _label3.bottom, KScreenWidth-120, 15);
_label5.frame = CGRectMake(_picimage.right+5, _label4.bottom, KScreenWidth-120, 15);
_label6.frame = CGRectMake(_picimage.right+5, _label5.bottom, KScreenWidth-120, 15);
 _sendbutton.frame = CGRectMake(KScreenWidth-160, _label6.bottom, 150, 20);
     [_sendbutton setImage:[UIImage imageNamed:@"我的-联系信"] forState:UIControlStateNormal];
    [_sendbutton setTitle:NSLocalizedString(@"发送信息", nil) forState:UIControlStateNormal];
    _sendbutton.titleLabel.font = [UIFont systemFontOfSize: 12.0];
      [_sendbutton layoutButtonWithEdgeInsetsStyle:MKButtonEdgeInsetsStyleLeft  imageTitleSpace:0];
      [_sendbutton setTitleColor:[UIColor colorWithHexString:@"0aa0f6"] forState:UIControlStateNormal];
_downview.frame = CGRectMake(0, _picimage.bottom+5, KScreenWidth, 5);
_label1.text = dict[@"pdcpName"];
_label2.text = dict[@"title"];
if([[NSString stringWithFormat:@"%@",dict[@"isPrice"]]isEqualToString:@"0    "]){
_label3.text = dict[@"pdPrice"];


}else{
_label3.text = [NSString stringWithFormat:@"%@ %@",NSLocalizedString(@"价格", nil),dict[@"pdPrice"]];
}
_label4.text = [NSString stringWithFormat:@"%@: %@",NSLocalizedString(@"商品详情-供货总量", nil),dict[@"totals"]];
    if([dict[@"sourceArea"] isEqual:[NSNull null]]){
_label5.text = [NSString stringWithFormat:@"%@: ",NSLocalizedString(@"商品详情-产地", nil)];

}else{
_label5.text = [NSString stringWithFormat:@"%@: %@",NSLocalizedString(@"商品详情-产地", nil),dict[@"sourceArea"]];


}
_label6.text = [NSString stringWithFormat:@"%@: %@",NSLocalizedString(@"发货日期", nil),dict[@"days"]];
//商品详情-价格
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
